package com.example.entity.dto.User;

import com.example.entity.auth.SysMenu;
import com.example.entity.auth.SysRole;
import com.example.entity.vo.auth.MesPermission;
import com.example.entity.vo.auth.YFPermission;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;

@Data
@AllArgsConstructor
public class MyUser implements UserDetails {

    private String username;
    private String name;
    private String password;
//    private List<SysMenu> permisses;
//    private List<SysRole> roles;
    private YFPermission yfPermission;
    private MesPermission mesPermission;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        SimpleGrantedAuthority simpleGrantedAuthority=new SimpleGrantedAuthority("GROUP_"+this.username);
        List list=new ArrayList<>();
        list.add(simpleGrantedAuthority);
        return list;
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
